package com.itheima.mapper;

import com.itheima.pojo.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author wuyiqiang
 * @2022/6/13 19:56
 */
@Mapper
public interface EmployeeMapper {

    /**
     * 员工登录
     *
     * @param employee
     * @return
     */
    @Select("select * from employee where username=#{username} and password=#{password}")
    Employee Login(Employee employee);

    /**
     * 分页查询
     *
     * @param name
     * @param pageMin
     * @param pageSize
     * @return
     */
    List<Employee> page(String name, Integer pageMin, Integer pageSize);

    /**
     * 计算总条数
     *
     * @return
     */
    @Select("select count(*) from employee")
    Integer countPage();

    /**
     * 新增员工
     *
     * @param employee
     * @return
     */
    @Insert("insert into employee values (#{id},#{username},#{name},#{password},#{phone},#{sex},#{idNumber},#{status}," +
            "#{createTime},#{updateTime},#{createUser},#{updateUser})")
    int add(Employee employee);

    /**
     * 修改员工
     * @param employee
     * @return
     */
    int update(Employee employee);

    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from employee where id=#{id}")
    Employee updateById(String id);
}
